package alg20241107;

import java.util.Scanner;

public class Text {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), q = in.nextInt();
        int[] arr = new int[n+1];
        for (int i = 1; i < arr.length; i++) {
            arr[i] = in.nextInt();
        }
        long[] dp = new long[n+1];
        dp[0] = 0;  //初始化
        for (int i = 1; i < n+1; i++) {
            dp[i] = dp[i - 1] + arr[i];
        }
        for (int i = 0; i < q; i++) {
            int l = in.nextInt(), r = in.nextInt();
            System.out.println(dp[r] - dp[l-1]);
        }
    }
}
